package com.wswy.wzcx.model.car

import android.os.Parcel
import android.os.Parcelable
import android.support.annotation.Keep
import android.text.TextUtils
import android.util.Log
import com.google.gson.annotations.SerializedName
import com.wswy.wzcx.model.ICity

data class JZGCity(@SerializedName("id") val id:String,
                   @SerializedName("name") val name:String?=null,
                   @SerializedName("firstLetter") val firstLetter:String?=null):Parcelable,ICity {


    override fun getCityName(): String? = name
    init {

    }

//    @delegate:Transient
//    val headerId by lazy {
//        var id:Long = 0
//        if (!TextUtils.isEmpty(firstLetter)){
//            id = firstLetter?.get(0)?.toLong()?:0
//        }
//        id
//    }

    override fun getNameLatter(): String? = firstLetter

    override fun getHeaderId() = if (!TextUtils.isEmpty(firstLetter)){
        firstLetter?.get(0)?.toLong()?:0
    }  else 0

    constructor(parcel: Parcel) : this(
            parcel.readString(),
            parcel.readString(),
            parcel.readString()) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(id)
        parcel.writeString(name)
        parcel.writeString(firstLetter)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<JZGCity> {
        override fun createFromParcel(parcel: Parcel): JZGCity {
            return JZGCity(parcel)
        }

        override fun newArray(size: Int): Array<JZGCity?> {
            return arrayOfNulls(size)
        }
    }
}